package com.ly.aps.system.provider.config;


import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 * Description: </br>
 * </br>
 * ClassName: Knife4JConfig
 * date: 2021/5/6 13:18
 *
 * @author LiXin
 * @version 1.0
 * @since JDK 1.8
 */

@Configuration
@EnableKnife4j
@EnableSwagger2WebMvc
public class Knife4JConfig {
    /**
     * @param
     * @return Docket
     * @description knife4j配置类
     * @author lixin
     * @date 2021/5/6 13:54
     */
    @Bean(value = "defaultApi2")
    public Docket defaultApi2() {
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                //分组名称
                .groupName("1.0版本")
                .select()
                //这里指定Controller扫描包路径(项目路径也行)
                .apis(RequestHandlerSelectors.basePackage("com.ly.aps.system.provider"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }

    /**
     * @param
     * @return ApiInfo
     * @description 接口文档信息
     * @author lixin
     * @date 2021/5/6 13:55
     */
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("系统管理接口")
                .description("系统管理API在线接口文档")
                .version("1.0")
                .build();
    }

}
